package com.qf.springbo.mybatis.mapper;

import com.qf.springbo.mybatis.entity.TUser;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserMapper {

    //根据id查询用户信息
    @Select("select * from t_user where id=#{id}")
    TUser getUserById(int id);

    //传入多个参数，添加一条用户信息
    @Insert("insert into t_user (username,sex)values(#{username},#{sex})")
    void addUser(@Param("username") String username, @Param("sex") char sex);

    //多个参数封装在一个pojo实体上，添加一条用户信息
    @Insert("insert into t_user (username,address)values(#{username},#{address})")
    void addUserEntity(TUser user);

    //根据id更新用户信息
    @Update("update t_user set username=#{username} where id=#{id}")
    void updateUser(@Param("username") String username, @Param("id") int id);

    //根据id删除用户信息
    @Delete("delete from t_user where id=#{id}")
    void deleteById(int id);

}
